package org.apache.osgimaker.analyse.algorithm.util;

/**
 * Logical AND Operation on a sequence of {@link StringPattern StringPatterns}.
 * 
 */
public class AndStringPattern extends StringPatternSequence
{
  /**
   * Creates instance with specified patterns.
   */
  public AndStringPattern(StringPattern... pattern)
  {
    super(pattern);
  }
  
  /**
   * Return <code>false</code> if a pattern in the sequence returns 
   * <code>false</code>. Otherwise <code>true</code> is returned.
   */
  public boolean matches(String string)
  {
    boolean result = true;
    for (int i = 0, n = _patterns.size(); i < n; i++)
    {
      if (!((StringPattern) _patterns.get(i)).matches(string))
      {
        result = false;
        break;
      }
    }
    return result;
  }

  protected String getOperatorSymbol()
  {
    return " & ";
  }
}
